<!DOCTYPE html>
<html>

<head>
    <title>原生json格式化及高亮</title>
    <meta name="description" content="json,格式化,高亮">
    <meta name="keywords" content="json,格式化,高亮">
    <script src="json/c.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/vendor/jquery-2.1.3.min.js"></script>
    <link href="json/s.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="HeadersRow">
    <textarea id="RawJson" style="display: none;" >

  </textarea>
</div>
<div id="ControlsRow">
    <input type="Button" value="format" onclick="Process()"/>
    <span id="TabSizeHolder">
    indent
    <select id="TabSize" onchange="TabSizeChanged()">
      <option value="1">1</option>
      <option value="2" selected="true">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
    </select>
  </span>
    <label for="QuoteKeys">
        <input type="checkbox" id="QuoteKeys" onclick="QuoteKeysClicked()" checked="true" />
        Quotes
    </label>&nbsp;
    <a href="javascript:void(0);" onclick="SelectAllClicked()">select all</a>
    &nbsp;
    <span id="CollapsibleViewHolder" >
      <label for="CollapsibleView">
        <input type="checkbox" id="CollapsibleView" onclick="CollapsibleViewClicked()" checked="true" />
        display control
      </label>
  </span>
    <span id="CollapsibleViewDetail">
    <a href="javascript:void(0);" onclick="ExpandAllClicked()">extend</a>
    <a href="javascript:void(0);" onclick="CollapseAllClicked()">fold</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(3)">2level</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(4)">3level</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(5)">4level</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(6)">5level</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(7)">6level</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(8)">7level</a>
    <a href="javascript:void(0);" onclick="CollapseLevel(9)">8level</a>
  </span>
</div>
<div id="Canvas" class="Canvas"></div>

<script type="text/javascript" src="json/m.js"></script>
<script type="text/javascript">

    var jsonstr = '' ;

    var type = getUrlParam('type');

    var posturl = '';
    var postvalue = '';

    //alert(nums);
    if( type == 'block' ){

        posturl = 'api/block/json'
        postvalue = getUrlParam('bocknum');

    }else if( type == 'tx' ){

        posturl = 'api/tx/json'
        postvalue = getUrlParam('txid');
    }

    $.ajax({
        type: "post",
        url: posturl,
        cache:false,
        async:true,
        dataType: "json",
        data: {"number":postvalue},

        success: function(response){

            var responsestr=JSON.stringify(response);
            $("#RawJson").text(responsestr);

            window.QuoteKeys = false;

            Process();

        },
        error:function(err){
        }

    });


    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }


</script>
</body>
</html>

